package com.example.lotterysystem.dao.mapper;

import com.example.lotterysystem.dao.dataobject.ActivityDO;
import org.apache.ibatis.annotations.*;

import java.util.List;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: Li_yizYa
 * Date: 2025/8/9
 * Time: 14:05
 */
@Mapper
public interface ActivityMapper {

    @Insert("insert into activity (activity_name, description, status) " +
            "values (#{activityName}, #{description}, #{status})")
    @Options(useGeneratedKeys = true, keyProperty = "id", keyColumn = "id")
    int insert(ActivityDO activityDO);

    @Select("select count(1) from activity")
    int count();

    @Select("select * from activity order by id desc limit #{offset}, #{pageSize}")
    List<ActivityDO> selectActivityList(Integer offset, Integer pageSize);

    @Select("select * from activity where id=#{activityId}")
    ActivityDO selectById(Long activityId);

    @Update("update activity set status=#{status} where id=#{id}")
    void updateStatus(@Param("id") Long id, @Param("status") String status);
}
